<template>
    <div>
       <h1>管理员登录</h1>
       <table class="table table-bordered">
        <tbody>
            <tr>
                <td align="right">账号</td>
                <td>
                    <input type="text" v-model="query.name"/>
                </td>
            </tr>
            <tr>
                <td align="right">密码</td>
                <td>
                    <input type="password" v-model="query.pass"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="登录" class="btn btn-primary" @click="ok"/>
                </td>
            </tr>
        </tbody>
       </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();
const route=useRoute();

import {useCounterStore} from '@/stores/use'
const ac=useCounterStore();


let query:any=reactive
({
    name:'',
    pass:''
})

const ok=()=>
{
    if(query.name=="")
    {
        alert("账号不能为空");
        return;
    }
    if(query.pass=="")
    {
        alert("密码不能为空");
        return;
    }
    axios
    ({
        url:'/api/Organ/LoGin',
        method:'get',
        params:query
    })
    .then(res=>{
        if(res.data==-1)
        {
          alert("账号错误");
          return;
        }
        if(res.data==-2)
        {
            alert("密码错误");
            return;
        }
        alert("登陆成功");
        ac.infor=res.data;
        router.push('/adminList');
        return;
    })
}


</script>

<style scoped>

</style>